using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using FireStarterModeller.BO;
using FireStarterModeller.Logic;
using FireStarterModeller.Test.BO;
using NUnit.Framework;

namespace FireStarterModeller.Test.Logic
{
    public static class UICreatorTestUtils
    {
        public static void AssertControlTypeIsComboBox(UIField formField, UIControlType controlType)
        {
            Assert.IsNotNull
                (controlType, "The UIControl Type should be ComboBox and Cannot be null");
            Assert.AreEqual("System.Windows.Forms", controlType.AssemblyName);
            Assert.AreEqual("ComboBox", controlType.TypeName);
        }

        public static void AssertControlTypeIsDateTimePicker(UIControlType controlType)
        {
            Assert.IsNotNull
                (controlType, "The UIControl Type should be ComboBox and Cannot be null");
            Assert.AreEqual("System.Windows.Forms", controlType.AssemblyName);
            Assert.AreEqual("DateTimePicker", controlType.TypeName);
        }

        public static void AssertControlTypeIsCheckBox(UIControlType controlType)
        {
            Assert.IsNotNull
                (controlType, "The UIControl Type should be CheckBox and Cannot be null");
            Assert.AreEqual("System.Windows.Forms", controlType.AssemblyName);
            Assert.AreEqual("CheckBox", controlType.TypeName);
        }

        public static void AssertFieldControlTypeIsTextBox(UIControlType controlType)
        {
            Assert.IsNotNull
                (controlType, "The FormField Control Type should be TextBox and Cannot be null");
            Assert.AreEqual("System.Windows.Forms", controlType.AssemblyName);
            Assert.AreEqual("TextBox", controlType.TypeName);
        }
        public static void AssertPropertyTypeIsLookup(DMProperty property)
        {
            Assert.IsNotNull(property.LookupList, "Property must have a lookup list");
        }

        public static void AssertPropertyTypeIsDateTime(DMProperty property)
                {
                    DMPropertyType propertyType = property.PropertyType;
                    Assert.IsNotNull(propertyType, "Property Type cannot be DateTime if it is null");
                    Assert.AreEqual("System", propertyType.AssemblyName);
                    Assert.AreEqual("DateTime", propertyType.PropertyTypeName);
                }
        public static void AssertPropertyTypeIsInt(DMProperty property)
        {
            DMPropertyType propertyType = property.PropertyType;
            Assert.IsNotNull(propertyType, "Property Type cannot be string if it is null");
            Assert.AreEqual("System", propertyType.AssemblyName);
            Assert.AreEqual("Int32", propertyType.PropertyTypeName);
        }

        public static void AssertPropertyTypeIsString(DMProperty property)
        {
            DMPropertyType propertyType = property.PropertyType;
            Assert.IsNotNull(propertyType, "Property Type cannot be string if it is null");
            Assert.AreEqual("System", propertyType.AssemblyName);
            Assert.AreEqual("String", propertyType.PropertyTypeName);
        }

        public static void AssertPropertyTypeIsBool(DMProperty property)
        {
            DMPropertyType propertyType = property.PropertyType;
            Assert.IsNotNull(propertyType, "Property Type cannot be string if it is null");
            Assert.AreEqual("System", propertyType.AssemblyName);
            Assert.AreEqual("Boolean", propertyType.PropertyTypeName);
        }

        public static DMClass CreateClassWithOneLookupProperty()
        {
            SolutionCreator creator = new SolutionCreator();
            DMProperty property = TestUtilsDMProperty.CreateUnsavedDefaultDMPropertyWithClass(creator.CreateSolution());
            TestUtilsDMProperty.SetDMPropWithLookupList(property);
            return (DMClass) property.Class;
        }
    }
}
